﻿using System.Text.RegularExpressions;

namespace Axiom.CodeManifold
{
	public static class stringExtensions
	{
		public static string GetAggregateRootName(this string input)
		{
			var result = string.Empty;

			if (Regex.Match(input, @"^(.*)ServiceClient.*$").Success)
			{
				result = Regex.Match(input, @"^(.*)ServiceClient.*$").Groups[1].ToString();
			}
			else if (Regex.Match(input, @"^(.*)Gateway.*$").Success)
			{
				result = Regex.Match(input, @"^(.*)Gateway.*$").Groups[1].ToString();
			}
			else if (Regex.Match(input, @"^(.*)Proxy.*$").Success)
			{
				result = Regex.Match(input, @"^(.*)Proxy.*$").Groups[1].ToString();
			}
			else if (Regex.Match(input, @"^I(.*)Service.*$").Success)
			{
				result = Regex.Match(input, @"^I(.*)Service.*$").Groups[1].ToString();
			}

			return result;
		}
	}
}
